package com.dhecp.project.business.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dhecp.common.core.domain.AjaxResult;
import com.dhecp.project.business.domain.ProductCarefullySetting;
import com.dhecp.project.business.mapper.ProductCarefullySettingMapper;
import com.dhecp.project.business.service.ProductCarefullySettingService;
import com.dhecp.project.system.service.SysDictionaryForFieldService;

/**
 * @program: kjecp
 * @description: 精品库服务类
 * @author: hlf
 * @create: 2023-03-13 10:05
 */
@Service
public class ProductCarefullySettingServiceImpl implements ProductCarefullySettingService {


    @Autowired
    private ProductCarefullySettingMapper productCarefullySettingMapper;

    @Autowired
    private SysDictionaryForFieldService dictionaryForFieldService;

    
    /**
     * 查询商品库
     * @param params
     * @return List - ProductCarefullyChosen
     * @throws Exception
     * @author DH-Xxj
     */
    @Override
    public List<ProductCarefullySetting> listByPcode(String pcode){

        return productCarefullySettingMapper.listByPcode(pcode);
    }
 

    /**
     * 通过guid查询单条商品库
     * @param guid
     * @return 实体 ProductCarefullyChosen
     * @author DH-Xxj
     */
    @Override
    public ProductCarefullySetting findByCodeAndPcode(String code, String pcode, String wareHouse) {
        return productCarefullySettingMapper.findByCodeAndPcode(code, pcode, wareHouse);
    }


    /**
     * 新增商品库
     * @param productActiveItems 必要参数：商品库对应实体类（ProductCarefullyChosen）的json格式字符串
     * @return
     * @author DH-Xxj
     */
    @Override
    public AjaxResult saveData(Map<String, Object> params) {
//        if (StringUtils.isEmpty(params)) {
//            return AjaxResult.error("数据提交失败，必填参数有误！");
//        }
//        ProductCarefullyChosen chosen = JSON.parseObject(params.get("infoItem").toString(), ProductCarefullyChosen.class);
//
//        if (chosen.getGuid() == null || "".equals(chosen.getGuid())){
//            chosen.setCreateTime(new Date());
//            chosen.setGuid(RandomValueUtils.getGUID());
//            productCarefullySettingMapper.insert(chosen);
//        }else{
//            productCarefullySettingMapper.update(chosen);
//        }

        return AjaxResult.success("操作成功");
    }

}